package xin.marcher.module.quality.remote;

import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Component;
import xin.marcher.module.common.core.JsonResult;
import xin.marcher.module.common.exception.BaseBizException;
import xin.marcher.module.construction.api.ProductApi;
import xin.marcher.module.construction.domain.dto.SaleSkuDTO;
import xin.marcher.module.construction.domain.request.QuerySaleSkuRequest;

/**
 * 商品 API
 */
@Component
public class ProductRemote {
    @DubboReference(version = "1.0.0")
    private ProductApi productApi;

    /**
     * 根据itemId集合批量查询item信息
     *
     * @param request
     * @return
     */
    public SaleSkuDTO getSkuDetail(QuerySaleSkuRequest request) {
        JsonResult<SaleSkuDTO> saleSkuResult = productApi.getSaleSku(request);

        if (!saleSkuResult.getSuccess()) {
            throw new BaseBizException(saleSkuResult.getErrorMessage(), saleSkuResult.getErrorCode());
        }

        return saleSkuResult.getData();
    }
}
